﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

public partial class MasterPageEmployee : System.Web.UI.MasterPage
{
    EmployeeMethord EM = new EmployeeMethord();
    protected void Page_Load(object sender, EventArgs e)
    {
        LeftMenuVacancy.Text = LoadLeftMenuVacancy();
        LeftMenuInterview.Text = LoadLeftMenuInterview();
        LeftMenuApplicant.Text = LoadLeftMenuApplicant();
    }
    private string LoadLeftMenuApplicant()
    {
        string LeftMenu = "";
        try
        {
            DataTable tb = EM.MenuTypeJob();
            if (tb.Rows.Count > 0)
            {
                foreach (DataRow item in tb.Rows)
                {
                    LeftMenu += "<dt><a class=\"\" href=\"\"><div class=\"listmanager\">";
                    LeftMenu += item["JobName"].ToString();
                    LeftMenu += "</div></a></dt>";
                    DataTable tb_Vacancy = EM.MenuVacancy(Convert.ToInt32(item["JobID"].ToString()));
                    if (tb_Vacancy.Rows.Count > 0)
                    {
                        LeftMenu += "<dd><ul>";
                        foreach (DataRow itemA in tb_Vacancy.Rows)
                        {
                            LeftMenu += "<li><a href=\"ApplicantApplyVacancy.aspx?ID=" + itemA["VacancyID"].ToString() + "\">" + itemA["Title"].ToString() + "</a></li>";
                        }
                        LeftMenu += "</ul></dd>";
                    }
                }
            }
        }
        catch (Exception ex)
        {
            Console.Write(ex.Message);
        }
        return LeftMenu;
    }
    private string LoadLeftMenuInterview()
    {
        string LeftMenu = "";
        try
        {
            DataTable tb =  EM.MenuTypeJob();
            if (tb.Rows.Count > 0)
            {
                foreach (DataRow item in tb.Rows)
                {
                    LeftMenu += "<dt><a class=\"\" href=\"\"><div class=\"listmanager\">";
                    LeftMenu += item["JobName"].ToString();
                    LeftMenu += "</div></a></dt>";
                    DataTable tb_Vacancy = EM.MenuVacancy(Convert.ToInt32(item["JobID"].ToString()));
                    if (tb_Vacancy.Rows.Count > 0)
                    {
                        LeftMenu += "<dd><ul>";
                        foreach (DataRow itemI in tb_Vacancy.Rows)
                        {
                            LeftMenu += "<li><a href=\"InterviewFollowVacancy.aspx?ID=" + itemI["VacancyID"].ToString() +"\">" + itemI["Title"].ToString() + "</a></li>";
                        }
                        LeftMenu += "</ul></dd>";
                    }
                }
            }
        }
        catch (Exception ex)
        {
            Console.Write(ex.Message);
        }
        return LeftMenu;
    }
    private string LoadLeftMenuVacancy()
    {
        string LeftMenu = "";
        try
        {
            DataTable tb =  EM.MenuTypeJob();
            if (tb.Rows.Count > 0)
            {
                foreach (DataRow item in tb.Rows)
                {
                    LeftMenu += "<dt><a class=\"active\" href=\"\"><div class=\"listmanager\">";
                    LeftMenu += item["JobName"].ToString();
                    LeftMenu += "</div></a></dt>";
                    DataTable tb_Vacancy = EM.MenuVacancy(Convert.ToInt32(item["JobID"].ToString()));
                    if (tb_Vacancy.Rows.Count > 0)
                    {
                        LeftMenu += "<dd><ul>";
                        foreach (DataRow itemV in tb_Vacancy.Rows)
                        {
                            LeftMenu += "<li><a href=\"VacancyDetails.aspx?ID=" + itemV["VacancyID"].ToString() + "\">" + itemV["Title"].ToString() + "</a></li>";
                        }
                        LeftMenu += "</ul></dd>";
                    }
                }
            }
        }
        catch (Exception ex)
        {
            Console.Write(ex.Message);
        }
        return LeftMenu;
    }
}
